.class public Lcom/netease/util/NetUtils;
.super Ljava/lang/Object;
.source "NetUtils.java"


# static fields
.field public static final NETWORK_TYPE_CMWAP:Ljava/lang/String; = "cmwap"

.field public static final TAG:Ljava/lang/String; = "NetUtils"


# direct methods
.method public constructor <init>()V
    .locals 0

    .prologue
    .line 18
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    return-void
.end method

.method public static getActiveNetworkType(Landroid/content/Context;)Ljava/lang/Integer;
    .locals 3
    .parameter "context"

    .prologue
    const/4 v2, 0x0

    .line 90
    invoke-static {p0}, Lcom/netease/util/NetUtils;->getConnectivityManager(Landroid/content/Context;)Landroid/net/ConnectivityManager;

    move-result-object v1

    .line 91
    .local v1, connectivity:Landroid/net/ConnectivityManager;
    if-nez v1, :cond_1

    .line 99
    :cond_0
    :goto_0
    return-object v2

    .line 95
    :cond_1
    invoke-virtual {v1}, Landroid/net/ConnectivityManager;->getActiveNetworkInfo()Landroid/net/NetworkInfo;

    move-result-object v0

    .line 96
    .local v0, activeInfo:Landroid/net/NetworkInfo;
    if-eqz v0, :cond_0

    .line 99
    invoke-virtual {v0}, Landroid/net/NetworkInfo;->getType()I

    move-result v2

    invoke-static {v2}, Ljava/lang/Integer;->valueOf(I)Ljava/lang/Integer;

    move-result-object v2

    goto :goto_0
.end method

.method private static getConnectivityManager(Landroid/content/Context;)Landroid/net/ConnectivityManager;
    .locals 3
    .parameter "context"

    .prologue
    .line 122
    const-string v1, "connectivity"

    invoke-virtual {p0, v1}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Landroid/net/ConnectivityManager;

    .line 123
    .local v0, connectivity:Landroid/net/ConnectivityManager;
    if-nez v0, :cond_0

    .line 124
    const-string v1, "NetUtils"

    const-string v2, "couldn\'t get connectivity manager"

    invoke-static {v1, v2}, Lcom/netease/util/Logger;->w(Ljava/lang/String;Ljava/lang/String;)V

    .line 126
    :cond_0
    return-object v0
.end method

.method private static getTelephonyManager(Landroid/content/Context;)Landroid/telephony/TelephonyManager;
    .locals 3
    .parameter "context"

    .prologue
    .line 135
    .line 136
    const-string v1, "phone"

    invoke-virtual {p0, v1}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v0

    .line 135
    check-cast v0, Landroid/telephony/TelephonyManager;

    .line 137
    .local v0, telephone:Landroid/telephony/TelephonyManager;
    if-nez v0, :cond_0

    .line 138
    const-string v1, "NetUtils"

    const-string v2, "couldn\'t get telephone manager"

    invoke-static {v1, v2}, Lcom/netease/util/Logger;->w(Ljava/lang/String;Ljava/lang/String;)V

    .line 140
    :cond_0
    return-object v0
.end method

.method public static isAvailable(Landroid/content/Context;)Z
    .locals 3
    .parameter "context"

    .prologue
    .line 44
    invoke-static {p0}, Lcom/netease/util/NetUtils;->getConnectivityManager(Landroid/content/Context;)Landroid/net/ConnectivityManager;

    move-result-object v0

    .line 45
    .local v0, connectivityManager:Landroid/net/ConnectivityManager;
    if-eqz v0, :cond_0

    .line 46
    invoke-virtual {v0}, Landroid/net/ConnectivityManager;->getActiveNetworkInfo()Landroid/net/NetworkInfo;

    move-result-object v1

    .line 47
    .local v1, networkInfo:Landroid/net/NetworkInfo;
    if-eqz v1, :cond_0

    .line 48
    invoke-virtual {v1}, Landroid/net/NetworkInfo;->isAvailable()Z

    move-result v2

    .line 51
    .end local v1           #networkInfo:Landroid/net/NetworkInfo;
    :goto_0
    return v2

    :cond_0
    const/4 v2, 0x0

    goto :goto_0
.end method

.method public static isCMWAP(Landroid/content/Context;)Z
    .locals 4
    .parameter "context"

    .prologue
    .line 62
    invoke-static {p0}, Lcom/netease/util/NetUtils;->getConnectivityManager(Landroid/content/Context;)Landroid/net/ConnectivityManager;

    move-result-object v0

    .line 63
    .local v0, connectivityManager:Landroid/net/ConnectivityManager;
    if-eqz v0, :cond_0

    .line 64
    invoke-virtual {v0}, Landroid/net/ConnectivityManager;->getActiveNetworkInfo()Landroid/net/NetworkInfo;

    move-result-object v1

    .line 65
    .local v1, networkInfo:Landroid/net/NetworkInfo;
    if-eqz v1, :cond_0

    invoke-virtual {v1}, Landroid/net/NetworkInfo;->getType()I

    move-result v2

    if-nez v2, :cond_0

    .line 66
    const-string v2, "cmwap"

    invoke-virtual {v1}, Landroid/net/NetworkInfo;->getExtraInfo()Ljava/lang/String;

    move-result-object v3

    invoke-virtual {v2, v3}, Ljava/lang/String;->equals(Ljava/lang/Object;)Z

    move-result v2

    if-eqz v2, :cond_0

    .line 67
    const/4 v2, 0x1

    .line 70
    .end local v1           #networkInfo:Landroid/net/NetworkInfo;
    :goto_0
    return v2

    :cond_0
    const/4 v2, 0x0

    goto :goto_0
.end method

.method public static isNetworkRoaming(Landroid/content/Context;)Z
    .locals 5
    .parameter "context"

    .prologue
    const/4 v3, 0x0

    .line 27
    invoke-static {p0}, Lcom/netease/util/NetUtils;->getConnectivityManager(Landroid/content/Context;)Landroid/net/ConnectivityManager;

    move-result-object v0

    .line 28
    .local v0, connectivityManager:Landroid/net/ConnectivityManager;
    invoke-static {p0}, Lcom/netease/util/NetUtils;->getTelephonyManager(Landroid/content/Context;)Landroid/telephony/TelephonyManager;

    move-result-object v2

    .line 29
    .local v2, telephonyManager:Landroid/telephony/TelephonyManager;
    if-eqz v0, :cond_0

    if-eqz v2, :cond_0

    .line 31
    invoke-virtual {v0}, Landroid/net/ConnectivityManager;->getActiveNetworkInfo()Landroid/net/NetworkInfo;

    move-result-object v1

    .line 32
    .local v1, info:Landroid/net/NetworkInfo;
    if-eqz v1, :cond_0

    invoke-virtual {v1}, Landroid/net/NetworkInfo;->getType()I

    move-result v4

    if-nez v4, :cond_0

    .line 33
    invoke-virtual {v2}, Landroid/telephony/TelephonyManager;->isNetworkRoaming()Z

    move-result v4

    if-eqz v4, :cond_0

    const/4 v3, 0x1

    .line 35
    .end local v1           #info:Landroid/net/NetworkInfo;
    :cond_0
    return v3
.end method

.method public static isWIFI(Landroid/content/Context;)Z
    .locals 3
    .parameter "context"

    .prologue
    const/4 v1, 0x1

    .line 79
    invoke-static {p0}, Lcom/netease/util/NetUtils;->getActiveNetworkType(Landroid/content/Context;)Ljava/lang/Integer;

    move-result-object v0

    .line 80
    .local v0, type:Ljava/lang/Integer;
    if-eqz v0, :cond_0

    invoke-virtual {v0}, Ljava/lang/Integer;->intValue()I

    move-result v2

    if-ne v2, v1, :cond_0

    :goto_0
    return v1

    :cond_0
    const/4 v1, 0x0

    goto :goto_0
.end method

.method public static isWifiEnabled(Landroid/content/Context;)Z
    .locals 2
    .parameter "context"

    .prologue
    .line 108
    const-string v1, "wifi"

    invoke-virtual {p0, v1}, Landroid/content/Context;->getSystemService(Ljava/lang/String;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Landroid/net/wifi/WifiManager;

    .line 109
    .local v0, wifiManager:Landroid/net/wifi/WifiManager;
    if-eqz v0, :cond_0

    .line 110
    invoke-virtual {v0}, Landroid/net/wifi/WifiManager;->isWifiEnabled()Z

    move-result v1

    .line 112
    :goto_0
    return v1

    :cond_0
    const/4 v1, 0x0

    goto :goto_0
.end method

.method public static setHttpProxy(Ljava/lang/String;Ljava/lang/String;)V
    .locals 2
    .parameter "proxy"
    .parameter "port"

    .prologue
    .line 149
    invoke-static {}, Ljava/lang/System;->getProperties()Ljava/util/Properties;

    move-result-object v0

    .line 150
    .local v0, systemProperties:Ljava/util/Properties;
    const-string v1, "http.proxyHost"

    invoke-virtual {v0, v1, p0}, Ljava/util/Properties;->setProperty(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Object;

    .line 151
    const-string v1, "http.proxyPort"

    invoke-virtual {v0, v1, p1}, Ljava/util/Properties;->setProperty(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/Object;

    .line 152
    return-void
.end method
